<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <button-counter></button-counter>
      <button-counter></button-counter>
      <button-counter></button-counter>
    </div>

    <script src="../Vue.js"></script>
    <script>
      Vue.component("button-counter", {
        // 在组件的data必须写成函数的形式，并且return对象
        // 要用到函数的作用域，使组件的data复用的时候不会相互干扰
        data() {
          return {
            count: 0,
          };
        },
        template:
          '<button v-on:click="count++">You clicked me {{ count }} times.</button>',
      });

      new Vue({
        el: "#app",
        data: {},
      });
    </script>
  </body>
</html>
